import datetime
from peewee import *

db = MySQLDatabase('cve', host="localhost", user='root', passwd='20011202', port=3306)


class Poc(Model):
    id = BigIntegerField(primary_key=True)
    gmt_create = DateTimeField(default=datetime.datetime.now)
    gmt_modified = DateTimeField(default=datetime.datetime.now)
    cve_name = CharField(default='')
    poc_links = CharField(default='[]')
    exploit_status = BooleanField(default=False)
    year = IntegerField(default=None)
    platform = CharField(default='')
    language = CharField(default='')
    note = CharField(default='')
    del_status = IntegerField(default=0)

    class Meta:
        database = db


class Cwe(Model):
    id = BigIntegerField(primary_key=True)
    gmt_create = DateTimeField(default=datetime.datetime.now)
    gmt_modified = DateTimeField(default=datetime.datetime.now)
    cwe_id = CharField(default='')
    cwe_name = CharField(default='')
    description = CharField(default='')
    extended_description = CharField(default='')
    url = CharField(default='')
    del_status = IntegerField(default=0)

    class Meta:
        database = db

    # def __str__(self):
    #     print('cwe name: {}'.format(self.cwe_id))


class CweClassification(Model):
    id = BigIntegerField(primary_key=True)
    gmt_create = DateTimeField(default=datetime.datetime.now)
    gmt_modified = DateTimeField(default=datetime.datetime.now)
    cve_name = CharField(default='')
    cwe_id = CharField(default='')
    del_status = IntegerField(default=0)

    class Meta:
        database = db
        table_name = 'cwe_classification'
